  <template>
	<view class="Caregiver">
		<image class="top" src="@/static/登录背景 (1).jpg"></image>
		<view class="text">
			<view class="t1">您好!<br>欢迎使用睿创鑫</view>
			<view class="t2">欢迎使用睿创鑫请填写您的信息进行登录</view>
		</view>
		<view class="formlist">
<!--      <u-action-sheet>-->
			<u-form :model="form" :rules="rules" ref="uForm" label-width="80" labelAlign="left">
				<u-form-item  prop="account" borderBottom ref="item1">
					<view class="lable">账号</view>
					<u--input v-model="form.account" border="none" placeholder="请填写姓名"></u--input>
				</u-form-item>
				<u-form-item prop="password" borderBottom ref="item1">
					<view class="lable">密码</view>
					<u--input v-model="form.password" border="none" placeholder="请输入密码" type="password" clearable></u--input>
				</u-form-item>
        <view style="display: flex">
          <uni-section>
            <uni-data-checkbox multiple v-model="radio1" :localdata="is"></uni-data-checkbox>
        </uni-section>
          <text @click="baomi" style="color: #2979ff;font-size: 14px;line-height: 25px;">数据安全保密协议书</text>
<!--          <uni-section>-->
<!--            <uni-link href="http://47.108.135.90:8442/cert/数据安全保密协议书.txt" text="签署数据安全保密协议书" color="#007BFF"></uni-link>-->
<!--          </uni-section>-->
        </view>
				<view class="uni-btn-v" @click="submit">登录</view>
				<view class="uni-btn-v" @click="tiaozhuan">开通账户</view>
			</u-form>
<!--			</u-action-sheet>-->
			<u-loading-page :loading="loading" bg-color="#e8e8e8" color="#000" loading-color="#000"
				loading-text="注册中..."></u-loading-page>
		</view>
	</view>
</template>

<script>
	//接口
	import {
		login
	} from '@/common/api.js';
	export default {
		data() {
			return {
        radio1: '',
        is: [{
          text: '已阅读并同意',
          value: 0
        }],
				loading: false,
				showSex: false,
				list: {
					type: 'success',
					message: "注册成功",
				},
				Sex: '',
        infor: {},
				form: {
					account: '',
					openid:'',
					password: '',
				},
				rules: {
					'account': {
						required: true,
						message: '请输入账号',
						trigger: ['blur']
					},
					'password': {
						required: true,
						// pattern: /^1[3456789]\d{9}$/,
						message: '请输入密码',
						trigger: 'blur'
					}
				}
			}
		},
		onLoad() {
      this.infor = uni.getStorageSync('infor');
    },
		onShow() {
			// this.GetDeptList()
		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			this.$refs.uForm.setRules(this.rules)
		},
		methods: {
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				this.index = e.detail.value
			},
			hideKeyboard() {
				uni.hideKeyboard()
			},
      baomi(){
        console.log('baomi')
        uni.navigateTo({
          url: '/subPackage/Function/Price/bmxy'
        })
      },
			//表单验证
      tiaozhuan() {
        // if (this.infor.account == 'admin'){
        uni.navigateTo({
          url: '/subPackage/Function/Price/ZHUCE'
        })
        // }else {
        //   uni.showToast({
        //     title: '正在开发中',
        //     icon: 'none',
        //     mask: true
        //   })
        // }
      },
			submit() {
				//性别赋值
				// if (this.Sex == '男') {
				// 	this.form.sex = 1
				// } else if (this.Sex == '女') {
				// 	this.form.sex = 2
				// }
        if (this.radio1 == '' || this.radio1 == null || this.radio1 == undefined){
          uni.showModal({
            content: '请先阅读并同意《数据安全保密协议书》',
            confirmText: '确定',
            showCancel: false,
            success(res) {
            },
          });
          return false;
        }
				this.$refs.uForm.validate().then(res => {
					console.log(this.form);
					// uni.$u.toast('校验通过')
					// this.form.openid = uni.getStorageSync('openid');
					this.form.openid = uni.getStorageSync('openid');
					login(this.form).then((res) => {
						console.log(res);
						if (res.code == 0) {
              uni.setStorageSync('account', this.form.account);
							//提示
							uni.showModal({
								content: '登录成功',
								confirmText: '去首页',
								showCancel: false,
								success(res) {
									uni.navigateBack({
										delta: 1 // 返回的页面数，如果 delta 大于现有页面数，则返回到首页
									})
								},
							});
						} else {
							uni.$u.toast(res.msg)
						}
					})
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})

			},
		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			this.$refs.uForm.setRules(this.rules)
		},
	};
</script>

<style>
	.top {
		position: absolute;
		z-index: -9999;
		width: 750rpx;
		height: 100vh;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
	}

	.Caregiver {
		/* margin-top: 270rpx; */
		/* background-color: white; */
	}

	.text{
		margin: 30rpx;
	}

	.t1{
		font-size: 48rpx;
		font-weight: bold;
		color: white;
	}

	.t2{
		font-size: 24rpx;
		color: white;
	}

	.formlist {
		margin: 420rpx 30rpx 0 30rpx;
		background-color: white;
		padding: 30rpx;
		border-radius: 30rpx;
	}

	.lable{
		font-size: 30rpx;
		font-weight: bold;
	}

	.uni-btn-v {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		background-color: #24d4b0;
		color: #fff;
		font-size: 35rpx;
		font-weight: bold;
		border-radius: 30rpx;
		text-align: center;
		margin-top: 30rpx;
	}
</style>
